package com.aplink.generic.pojo.controlspec;

import java.util.ArrayList;

public class ViewPagerSpec extends ControlSpec {
    private String mDefaultTarget;
    private ArrayList<ViewPagerItem> mViewPagerItems;
    private String mHeaderStyle;
    private boolean isLoadByConfig;
    private int mStartPage = 0;

    public ViewPagerSpec( int currentPage,
                          ArrayList<ViewPagerItem> viewPagerItems ) {
        setStartPage( currentPage );
        this.mViewPagerItems = viewPagerItems;
        isLoadByConfig = true;
    }

    public ViewPagerSpec( int currentPage,
                          ArrayList<ViewPagerItem> viewPagerItems, String headerStyle,
                          boolean isLoadByConfig ) {
        setStartPage( currentPage );
        mViewPagerItems = viewPagerItems;
        mHeaderStyle = headerStyle;
        this.isLoadByConfig = isLoadByConfig;
    }

    public ViewPagerSpec() {
        mViewPagerItems = new ArrayList<ViewPagerSpec.ViewPagerItem>();
    }

    public String getDefaultTarget() {
        return this.mDefaultTarget;
    }

    public void setDefaultTarget( String currentPage ) {
        this.mDefaultTarget = currentPage;
    }

    public int getDefaultTargetIndex() {
        for ( int i = 0 ; i < mViewPagerItems.size() ; i++ ) {
            if ( mViewPagerItems.get( i ).mPagerItemClass
                    .equalsIgnoreCase( mDefaultTarget ) ) {
                return i;
            }
        }
        return 0;
    }

    public ArrayList<ViewPagerItem> getViewPagerItems() {
        return this.mViewPagerItems;
    }

    public void setViewPagerItems( ArrayList<ViewPagerItem> viewPagerItems ) {
        this.mViewPagerItems = viewPagerItems;
    }

    public void add( ViewPagerItem pagerItem ) {
        mViewPagerItems.add( pagerItem );
    }

    public String getHeaderStyle() {
        return mHeaderStyle;
    }

    public void setHeaderStyle( String headerStyle ) {
        this.mHeaderStyle = headerStyle;
    }

    public boolean isLoadByConfig() {
        return isLoadByConfig;
    }

    public void setLoadByConfig( boolean isLoadByConfig ) {
        this.isLoadByConfig = isLoadByConfig;
    }

    public int getStartPage() {
        return mStartPage;
    }

    public void setStartPage( int startPage ) {
        mStartPage = startPage;
    }

    public class ViewPagerItem {
        private String mPagerItemClass;
        private String mTitle;
        private String mIcon;

        public String getClassName() {
            return this.mPagerItemClass;
        }

        public void setPagerItemClass( String pagerItemClass ) {
            this.mPagerItemClass = pagerItemClass;
        }

        public String getTitle() {
            return this.mTitle;
        }

        public void setTitle( String title ) {
            this.mTitle = title;
        }

        public String getIcon() {
            return this.mIcon;
        }

        public void setIcon( String icon ) {
            this.mIcon = icon;
        }

        public ViewPagerItem() {

        }

        public ViewPagerItem( String pagerItemClass, String title, String icon ) {
            this.mPagerItemClass = pagerItemClass;
            this.mTitle = title;
            this.mIcon = icon;
        }
    }
}
